<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="../css/order.css"/>
</head>
<body class="gray">
	<div id="refreshContainer" class="mui-content mui-scroll-wrapper ">
		<div class="mui-scroll loading" id="vueMain">
			<div v-if="list.length==0">
				<p style="padding:50px 0;text-align: center;">没有询价的哦!</p>
			</div>
			<template v-for="(item,index) in list">
				<ul class="mui-table-view">
				     <li class="mui-table-view-cell tls">询价日期:{{item.add_time}}</li>
				     <li class="mui-table-view-cell mui-media">
			        		<a href="javascript:;">
		    		            <img class="mui-media-object mui-pull-left link" :src="item.img" _id="productDetail" _href="productDetail.html" _title="产品详情" :_extras="'gid='+item.goods_id" />
		    		            <div class="mui-media-body link" _id="enquiryDetail" _href="enquiryDetail.html" _title="询价详情" :_extras="'eid='+item.id">
		    		                <div class="name">{{item.name}}</div>
		    		                <p>日期:{{splitDate(item.activity_time)}}</p>
		    		                <p v-if="item.activity_type.length != 0">类型:{{splitType(item.activity_type[0])}}</p>
		    		                <p v-if="item.activity_type.length != 0">预算:{{splitType(item.activity_type[1])}}</p>
		    		            </div>
		    		        </a>
			        </li>
				</ul>
			</template>
		</div>
	</div>
<script src="../js/mui.js"></script>
<script src="../js/vue.min.js"></script>
<script src="../js/bexta.js"></script>
<script type="text/javascript">
	var apps, views, merchant,first = 0, last = 10;
	mui.plusReady(function () {
		views = bexta.getWebview();
	    merchant = bexta.getStorage(MERCHANT);
	    bexta.ajax(api.consult_order, function(res){
	    		initVue(res);
	    }, {data:{uid:merchant.uid, firstrow:first, listrow:last}});
	});
	function initVue(res){
		apps = new Vue({
			el:"#vueMain",
			data:{
				list:res,
				first:res.length,
				last:last
			},
			methods:{
				splitDate:function(v){
					var s = v.split('至');
					return s[0].replace(/\-/g, '.') + " - " + s[1].replace(/\-/g, '.');
				},
				splitType:function(v){
					console.log( v )
					return v.split(':')[1];
				}
				
			},
			mounted:function(){
				var self = this
				document.querySelector('.loading').classList.add('loadRun');
				mui.init({
				  	pullRefresh : {
				    		container:"#refreshContainer",
				    		down:{
				    			height:50,
				    			auto:false,
				    			callback:function(){
				    				 bexta.ajax(api.consult_order, function(res){ 
				    				 	self.list = res;
				    				 	mui('#refreshContainer').pullRefresh().endPulldownToRefresh();
				    				 }, {data:{uid:merchant.uid, firstrow:0, listrow:self.first}});
				    			}
				    		},
					    up : {
					      	height:50,
					      	auto:false,
					      	contentrefresh : "正在加载...",
					      	contentnomore:'没有更多数据了',
					      	callback :function(){
					      		var that = this;
					      		bexta.ajax(api.consult_order, function(res){
					      			var len = res.length;
					      			if( len == 0 || len < self.last ){
					      				that.endPullupToRefresh(true);
					      			}else{
					      				that.endPullupToRefresh(false);
					      			}
					      			if( len > 0 ){
					      				mui.each(res, function(){
					      					self.list.push(this);
					      				});
					      				self.first += len;
					      			}
					      		}, {data:{uid:merchant.uid, firstrow:self.first, listrow:self.last}})
					      	}
					    }
				  	}
				});
			}
		})
		
	}
</script>
</body>
</html>